package com.micro.business.common.util;

import java.util.Random;

/**
 * <P>随机数工具类</P>
 *
 * @author 高仕立
 * @date 2019/8/1 9:05 AM
 * @since
 */
public class RandomUtil {

    /**
     * 获取指定长度的随机字符串
     *
     * @param length 字符串长度
     * @return 随机字符串
     */
    public static String getRandomString(int length) {
        StringBuilder buffer = new StringBuilder("23456789abcdefghjkmnpqrstuvwxyz");
        StringBuilder sb = new StringBuilder();
        Random r = new Random();
        int range = buffer.length();
        for (int i = 0; i < length; i++) {
            sb.append(buffer.charAt(r.nextInt(range)));
        }
        return sb.toString();
    }
}
